home *** CD-ROM | disk | FTP | other *** search
/ IRIX Installation Tools & Overlays 2002 November / SGI IRIX Installation Tools & Overlays 2002 November - Disc 4.iso / dist / motif21_dev.idb / usr / share / src / X / motif-2.1 / osf_demos / tools / wml / README.z / README
Text File  |  2002-10-15  |  15KB  |  417 lines

  1. /* $XConsortium: README /main/4 1996/07/15 14:38:42 drk $ */
  2. This memo documents the Widget MetaLanguage (WML) facility which generates
  3. the Uil compiler language description.
  4.  
  5. 1. Introduction
  6.  
  7. The Uil compiler's language definition has the following components:
  8.     - Invariant parts of the language grammar. This consists of the
  9.       basic syntax and keywords, for example, the 'arguments' directive.
  10.     - Dynamic parts of the language. This consists of the widget/gadget
  11.       classes supported by the language, including all resources
  12.       (arguments and reasons), and the definitions of legal relationships
  13.       among these parts (which classes are legal controls (children)
  14.       of any given class, default values, and so on).
  15.     - The data types supported by the compiler. The code which supports
  16.       the data types is invariant, but the data types must also be
  17.       declared and made known in WML in order to provide a clean
  18.       specification.
  19.  
  20. The dynamic parts of the language definition in the compiler are represented
  21. as follows. The representation falls into two classes:
  22.     - Definitions of the language used for validity checking and
  23.       reporting:
  24.         o A set of #define literals name all data types, classes,
  25.           arguments, and reasons in the language.
  26.         o A set of statically compiled tables defines the names and
  27.           legal relationships among these entities.
  28.     - All data types, classes, arguments, and reasons are treated as
  29.       keywords in the Uil grammar. This is supported by:
  30.         o A set of #define literals which names all the tokens in
  31.           the language. Some of these tokens receive identical
  32.           values to the literals mentioned above (this identity is
  33.           crucial to the compiler's correct functioning).
  34.         o A set of statically compiled tables used by lexical
  35.           analysis to detect and classify the language keywords.
  36.         o A yacc grammar including these token definitions which
  37.           generates a compilable Uil language parser.
  38.  
  39. These representations are all contained in .h files except for the parser,
  40. which is contained in a .y file and its resulting .c file.
  41.  
  42. The WML system's task is to generate all these literals and tables based on
  43. a specification of the dynamic parts of the Uil language - the data types,
  44. widget/gadget classes, arguments, and reasons. The components of the system
  45. are:
  46.     - A specification of the of set of widgets to be supported. This
  47.       specification is an ASCII file containing a WML language
  48.       specification as described below. The WML language is a simple
  49.       declarative language whose syntax is similar to Uil itself.
  50.     - A process named wml, which parses the WML specification and
  51.       produces the following output:
  52.         o The .h files which define the first class of language
  53.           representations - the validity checking and reporting
  54.           information.
  55.         o A set of .dat files which are used by succeeding processes
  56.           to produce the Uil grammar.
  57.         o A report file which describes the toolkit being supported.
  58.         o A .mm file to be incorporated in the Uil language
  59.           documentation, which tabulates the built-in language
  60.           tables for Uil user reference.
  61.     - A process named wmluily which generates the Uil grammar.
  62.     - A process named wmltokens which generates token data
  63.     - A process named wmlkeyword which generates the token and lexical
  64.       analysis tables.
  65.  
  66. A shell script is provided which runs the system. The individual processes
  67. and inputs can usually be ignored.
  68.  
  69.  
  70. 2. Environment
  71.  
  72. The generation and use of the WML system requires the following:
  73.     - The C language compiler and runtime system (cc).
  74.     - The lexical generator facility (lex)
  75.     - the compiler compiler facility (yacc)
  76.  
  77. The WML facility is found in directory /wmlsrc. It assumes the following
  78. directories also exist:
  79.     /uilsrc - the directory to which the output files are to be moved
  80.     /mrmsrc/Mrm - contains MrmCmpr.h and other .h files required to
  81.         compile the uil compiler.
  82.  
  83. The tables produced by WML must be consistent with the Mrm compression
  84. code tables emboded in /mrmsrc/Mrm/MrmCmpr.h and /mrmsrc/Mrm/MrmCmprTbl.h.
  85. If in doubt, refer to /mrmsrc/Mrm/urmc.README for details.
  86.  
  87.  
  88. 3. WML input
  89.  
  90. Input to WML consists of:
  91.     - A description of the widget set (toolkit) to be suppported in
  92.       the WML specification language.
  93.     - Data files supplied with WML facility, and which you will
  94.       usually not need to modify. These are:
  95.         o grammar.y    - specifies the invariant part of the
  96.                   Uil grammar
  97.         o charset.dat    - specifies the character sets supported by
  98.                   the compiler when handling compound strings
  99.       Any other .dat files found in /wmlsrc are the result of running
  100.       the facility, and may be ignored.
  101.  
  102. 3.A. WML specification language
  103.  
  104. The WML specification is a simple declarative language whose syntax is
  105. similar to that of Uil itself. It models the widget set to be suppored in
  106. a way that is very similar to the Uil language. It differs in having class
  107. inheritance similar to Xt widget classes, which minimizes the amount of
  108. specification and reduces errors. The properties of the model are:
  109.     - Class properties
  110.         o Classes are differentiated into two types - metaclasses
  111.           and classes. Metaclasses cannot instantiate widgets.
  112.           Typically, a WML metaclass is generated for each metaclass
  113.           in the widget set to be supported.
  114.         o A regular class is defined for every low-level create
  115.           routine in the widget set. There are typically more WML
  116.           classes that widget set classes. For instance, there
  117.           is one XmRowColumn class, with six WML classes (XmRowColumn
  118.           XmMenuBar, XmOptionMenu, XmPopupMenu, XmPulldownMenu,
  119.           XmRadioBox).
  120.         o Gadgets are modelled as variants of a corresponding
  121.           widget class.
  122.         o A class may have zero or one superclasses. A class
  123.           inherits all the resources and controls of its superclass
  124.           (recursively). An inherited resource may have some of
  125.           its properties overridden.
  126.         o A class is given a name which becomes its Uil language
  127.           keyword (for regular classes). Metaclass names do
  128.           not appear in Uil.
  129.         o A class is identified to Mrm by its creation
  130.           convenience function (low-level create function). Examples
  131.           are XmCreateLabel, XmCreatePushButtonGadget.
  132.     - Resource properties
  133.         o Resources are divided into two classes - arguments and
  134.           and reasons. This models the Uil language distinction
  135.           between callbacks and all other resources.
  136.         o A resource is considered to have universal scope. Once
  137.           defined, it may be used in any class. Its name and datatype
  138.           are invariant, but its default value may be overridden.
  139.         o A resource is included in a class by referencing it.
  140.           Resources are inherited. Inherited resources may be
  141.           excluded, which meancs they are not available in the
  142.           class which provides this override (and its subclasses).
  143.           This corresponds to the Motif toolkit N/A access value.
  144.         o A resource is given a name which becomes its Uil language
  145.           keyword.
  146.         o A resource is identified to Mrm by the toolkit literal
  147.           used to name it in arglists. Examples are
  148.           XmNheight, XmNancestorSensitive, XmNhelpCallback. The
  149.           resource literal defaults to the resource name, and need
  150.           not be explicitly specified where they are identical.
  151.     - Control properties
  152.         o A control is a class which is permitted as the child
  153.           of some other class.
  154.         o Naming the controls of a class is a WML feature which
  155.           supports validity checking. There is no coresponding
  156.           explicit feature in any Xt widget set.
  157.  
  158. 3.A.1 WML syntax and semantics
  159.  
  160. The WML syntax can be quickly inferred from the standard input file
  161. provided with WML - motif-tables.wml. A quick BNF is provided in section 7.
  162.  
  163.  
  164. WML semantics are:
  165.     - '!' introduces a comment. Comments run from '!' to EOL.
  166.     - A string value may be quoted by enclosing in double quotes '"'.
  167.       Names as well as values may be quoted. Keywords may not.
  168.     - All names are case-sensitive. Forward and backward references
  169.       are allowed. All references to be resolved are to items defined
  170.       in WML. These are:
  171.         o Type = <an item defined in a DataType statement>
  172.         o SuperClass =
  173.           WidgetClass = <an item defined in a Class statement>
  174.         o Resources { <items defined in Resource statement> };
  175.         o Controls { <items defined in Class or ControlList>
  176.                 statements> };
  177.     - A convenience function name is required for all classes except
  178.       Metaclasses.
  179.     - Datatypes are required for all Arguments, Constraints, and
  180.       SubResources.
  181.     - Arguments and SubResources are functionally identical, and
  182.       are distinguished only because they are different kinds of
  183.       resources in Xt widget sets. Constraints apply only to the
  184.       referencing class's children. The same name may not be
  185.       used for both an Argument and a Constraint (once a Constraint,
  186.       always a Constraint).
  187.     - If a resource occurs in the widget set with more than one
  188.       datatype, the Uil datatype 'any' must be used.
  189.     - The ResourceLiteral attribute for resources is optional, and
  190.       need only be specified when the name is not identical to the literal.
  191.     - The DocName and Default attributes are only used for documentation.
  192.       They are arbitrary strings.
  193.     - The WidgetClass attribute identifies the Widget class
  194.       associated with a Gadget class, and is required.
  195.     - The DialogClass attribute is optional.
  196.     - The ControlList statement is a simply macro for lists of
  197.       controls. It avoids tedious repetition of identical lists.
  198.       A Controls block in a Class statement allows Class and
  199.       ControlList names to be freely mixed.
  200.  
  201.  
  202. 4. WML output
  203.     - The .h files and parser required by the compiler. These
  204.       are automatically moved to /uilsrc by the runwml script.
  205.     - A report describing the supported widget set, always named
  206.       wml.report. This report is intended to aid in validating
  207.       the WML source. The report is organized in a way which makes
  208.       if fairly easy to compare the Uil langauge against widget
  209.       set documentation as exemplified by the Motif Programmer's
  210.       Reference Manual. The reported is sorted as follows:
  211.         - alphabetically by class name
  212.         - Resources ordered by ancestor (top of tree first).
  213.           Resources are listed alphabetically, with datatype
  214.           and default always shown.
  215.         - Reasons ordered by ancestor (top of tree first),
  216.           then alphabetically.
  217.         - Controls listed alphabetically.
  218.     - A file which provides documentation for the language, intended
  219.       to be an appendix to a Uil manual as exemplified by the
  220.       Guide to the Motif User Interface Language Compiler. This file
  221.       is named wml-uil.mm
  222.  
  223.  
  224. 5. Generating and running WML
  225.  
  226. The script file /wmlsrc/genwml will build WML. The script file /wmlsrc/runwml
  227. will run WML with motif-tables.src as input.
  228.  
  229.  
  230. 6. Gotchas and problems in current WML implementation
  231.  
  232. The script files genwml and runwml should be replaced by Makefiles.
  233.  
  234. The documentation file ?.mm is relatively untested. The tables should
  235. probably be modified, as they are currently too big to print cleanly.
  236. The handling of the DocName attribute is incorrect.
  237.  
  238. The specification of the Motif toolkit in motif-tables.wml has not been
  239. fully validated against the latest toolkit documentation. We believe there
  240. are no or very few errors in the actual resources and the classes which
  241. use them. There may be errors in the default values, which will appear
  242. in the documentation.
  243.  
  244.  
  245. 7. WML BNF
  246.  
  247. WML-specification : statement_block_list
  248.  
  249. statement_block_list:
  250.     <empty>
  251.     statement_block_list statement_block
  252.  
  253. statement_block:
  254.     class_statement_block
  255.     | resource_statement_block
  256.     | datatype_statement_block
  257.     | control_list_statement_block
  258.  
  259. class_statement_block:
  260.     'Class' class_statement_list
  261.  
  262. resource_statement_block:
  263.     'Resource' resource_statement_list
  264.  
  265. datatype_statement_block:
  266.     'Datatype' datatype_statement_list
  267.  
  268. control_list_statement_block:
  269.     'ControlList' control_list_statement_list
  270.  
  271. class_statement_list:
  272.     class_statement ';'
  273.     | class_statement_list class_statement ';'
  274.  
  275. resource_statement_list:
  276.     resource_statement ';'
  277.     | resource_statement_list resource_statement ';'
  278.  
  279. datatype_statement_list:
  280.     datatype_statement ';'
  281.     | datatype_statement_list datatype_statement ';'
  282.  
  283. control_list_statement_list:
  284.     control_list_statement ';'
  285.     | control_list_statement_list control_list_statement ';'
  286.  
  287. class_statement:
  288.     <name> ':' class_type class_definition
  289.  
  290. class_type:
  291.     'MetaClass' | 'Widget' | 'Gadget'
  292.  
  293. class_definition:
  294.     <empty>
  295.     | '{' '}'
  296.     | '{' class_attribute_list '}'
  297.  
  298. class_attribute_list:
  299.     class_attribute_name '=' <string> ';'
  300.     | class_boolean_attribute_name '=' boolean_attribute_value ';'
  301.     | class_resources ';'
  302.     | class_controls ';'
  303.  
  304. class_attribute_name:
  305.     'SuperClass' | 'Alias' | 'ConvenienceFunction' | 'WidgetClass' |
  306.     'DocName'
  307.  
  308. class_boolean_attribute_name:
  309.     'DialogClass'
  310.  
  311. boolean_attribute_value:
  312.     'True' | 'False'
  313.  
  314. class_resources:
  315.     'Resources' class_resources_block
  316.  
  317. class_resources_block:
  318.     <empty>
  319.     '{' '}'
  320.     '{' class_resource_list '}'
  321.  
  322. class_resource_list:
  323.     class_resource_element
  324.     | class_resource_list class_resource_element
  325.  
  326. class_resource_element:
  327.     <name> class_resource_attributes ';'
  328.  
  329. class_resource_attributes:
  330.     <empty>
  331.     '{' '}' ';'
  332.     '{' class_resource_attribute_list '}'
  333.  
  334. class_resource_attribute_list:
  335.     class_resource_attribute_element
  336.     | class_resource_attribute_list class_resource_attribute_element
  337.  
  338. class_attribute_element
  339.     class_resource_attribute_name '=' <string> ';'
  340.     | boolean_class_resource_attribute_name '=' boolean_attribute_value ';'
  341.  
  342. class_resource_attribute_name:
  343.     'Default'
  344.  
  345. boolean_class_resource_attribute_name:
  346.     'Exclude'
  347.  
  348. class_controls:
  349.     'Controls' class_controls_block
  350.  
  351. class_controls_block:
  352.     <empty>
  353.     | '{' '}' ';'
  354.     | '{' class_controls_list '}'
  355.  
  356. class_controls_list:
  357.     class_controls_element
  358.     class_controls_list class_controls_element
  359.  
  360. class_controls_element:
  361.     <name> ;
  362.  
  363. resource_statement:
  364.     <name> ':' resource_type resource_definition
  365.  
  366. resource_type:
  367.     'Argument' | 'Reason' | 'Constraint' | 'SubResource'
  368.  
  369. resource_definition:
  370.     <empty>
  371.     '{' '}'
  372.     '{' resource_attribute_list '}'
  373.  
  374. resource_attribute_list:
  375.     resource_attribute
  376.     resource_attribute_list resource_attribute
  377.  
  378. resource_attribute:
  379.     resource_attribute_name '=' <string> ';'
  380.  
  381. resource_attribute_name:
  382.     'Type' | 'ResourceLiteral' | 'Alias' | 'Related' | 'Default' |
  383.     'DocName'
  384.  
  385. datatype_statement:
  386.     <name> datatype_definition
  387.  
  388. datatype_definition:
  389.     <empty>
  390.     | '{' '}'
  391.     | '{' datatype_attribute_list '}'
  392.  
  393. datatype_attribute_list:
  394.     datatype_attribuute
  395.     datatype_attribute_list datatype_attribute
  396.  
  397. datatype_attribute:
  398.     datatype-attribute_name '=' <string> ';'
  399.  
  400. datatype_attribute_name:
  401.     'Alias' | 'DocName'
  402.  
  403. control_list_statement:
  404.     <name> control_list_definition
  405.  
  406. control_list_definition:
  407.     <empty>
  408.     '{' '}'
  409.     '{' control_list_controls_list '}'
  410.  
  411. control_list_controls_list:
  412.     control_list_control
  413.     control_list_controls_list control_list_control
  414.  
  415. control_list_control:
  416.     <name> ';'
  417.